<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person(name,age){
            this.name = name
            this.age = age
        }
        Person.prototype.sayAge = function(){
            console.log(this.name);
        }
        var p = new Person("li",20)
        console.log(p);

        // 在数组原型上定义一个升序的方法
        var arr = [1,5,6,3,2]
        Array.prototype.update = function(params){
            if(Array.isArray(params)){
                return params.sort((a,b)=>a-b)
            }
        }
        console.log(arr.update(arr));
    </script>
</body>
</html>